package com.qzsoft.zhjd.materiel.modules.materieldata.dto;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import lombok.Data;

/**
 * @ClassName MaterielDataCountDto
 * @Description 物料统计信息
 * @author linhuawei
 * @since 2021-09-01
 */
@Data
public class MaterielDataCountTypeDto {

    /**
     * 过磅重量
     */
    private BigDecimal weight;

    /**
     * 过磅批次
     */
    private Integer batch;

    /**
     * 详情
     */
    private List<MaterielDataCountTypeListDto> list;

    public void count() {
        weight = BigDecimal.ZERO;
        batch = 0;
        if (null != list) {
            for (MaterielDataCountTypeListDto dto : list) {
                if (null != dto.getWeight()) {
                    weight = weight.add(dto.getWeight());
                }
                if (null != dto.getBatch()) {
                    batch = batch + dto.getBatch();
                }
            }
        } else {
            list = new ArrayList<MaterielDataCountTypeListDto>();
        }
    }
}
